<?php

class Getpwd_phone_model extends CI_Model
{
    private $table = 'getpwd_phone';

    /**
     * @descripte   发货提醒 限制用户恶意发送短信 插入
     * @Author xiumao
     * @date 2016/6/14 0014 上午 11:07
     */
    public function insertSms($username, $telephone, $content)
    {
        $data = array(
            'username' => $username,
            'phone'    => $telephone,
            'code'     => md5($content),
            'addtime'  => date('Y-m-d H:i:s', time()),
            'failtime' => date('Y-m-d H:i:s', (time() + 3600)),
            'flag'     => 0,
        );
        $this->db->insert($this->table, $data);

        return $this->db->insert_id();
    }

    /**
     * @descripte   发货提醒 限制用户恶意发送短信 查找
     * @Author xiumao
     * @date 2016/6/14 0014 上午 11:22
     */
    public function selectOneSmsByPhone($phone,$code)
    {
        $this->db->where('phone', $phone);
        $this->db->where('code', $code);
        $this->db->order_by('id', 'desc');
        $this->db->limit(1);
        return $this->db->get($this->table);
    }
}